#include <stdio.h>
#include <string.h>
#include <stdlib.h>


int main(int argc, char *argv[]) {

    char c;
    int array[1000];
    int b, count = 0, i = 0;

    while ((c = getchar()) != ' ') {
        array[count++] = c - '0';
    }

    scanf("%d", &b);

    int flag = 0, remainder = 0;
    for (i = 0; i < count; i++) {
        int result = (remainder * 10 + *(array + i)) / b;
        remainder = (remainder * 10 + *(array + i)) % b;
        if (result == 0) {
            if (flag || count == 1) printf("%d", result);
            flag = 1;
        } else {
            printf("%d", result);
            flag = 1;
        }
    }

    printf(" %d\n", remainder);

    return 0;
}
